package com.example.demo.controller;


import com.example.demo.model.MessageRankDto;
import com.example.demo.service.IMessageRankService;
import com.example.demo.service.IRedisOnlineService;
import com.example.demo.vo.RestResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年03月24日 星期一 14:30:31
 */
@RestController
@Controller
@RequestMapping("/chatApi")
@Api(value = "聊天室相关接口", tags = {"聊天室相关接口"})
public class ChatController {

    @Autowired
    private IRedisOnlineService redisOnlineService;

    @Autowired
    private IMessageRankService messageRankService;

    @GetMapping("getOnlineUsers")
    @ApiOperation("获取在线用户列表")
    public RestResultVo<Set<String>> getOnlineUsers(){
        Set<String> onlineUser = redisOnlineService.getOnlineUser();
        return RestResultVo.ok(onlineUser);
    }

    // 获取消息排行榜
    @GetMapping("getTopUserMessage")
    @ApiOperation("获取消息排行榜")
    public RestResultVo<List<MessageRankDto>> getMessageRank(){
        List<MessageRankDto> messageRankList = messageRankService.getMessageRankList();
        return RestResultVo.ok(messageRankList);
    }

}
